package com.ruoyi.web.controller.comprehensive;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.comprehensive.domain.PreventionExamine;
import com.ruoyi.comprehensive.dto.PreventionExamineDto;
import com.ruoyi.comprehensive.service.IPreventionExamineService;
import com.ruoyi.comprehensive.vo.PreventionExamineVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 通防审核Controller
 * 
 * @author hcc
 * @date 2023-12-16
 */
@RestController
@RequestMapping("/comprehensive/measuresExamine")
public class PreventionExamineController extends BaseController
{
    @Autowired
    private IPreventionExamineService preventionExamineService;

    /**
     * 查询通防审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:measuresExamine:list')")
    @GetMapping("/list")
    public TableDataInfo list(PreventionExamine preventionExamine)
    {
        startPage();
        List<PreventionExamine> list = preventionExamineService.selectPreventionExamineList(preventionExamine);
        return getDataTable(list);
    }

    /**
     * 导出通防审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:measuresExamine:export')")
    @Log(title = "通防审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PreventionExamine preventionExamine)
    {
        List<PreventionExamine> list = preventionExamineService.selectPreventionExamineList(preventionExamine);
        ExcelUtil<PreventionExamine> util = new ExcelUtil<PreventionExamine>(PreventionExamine.class);
        util.exportExcel(response, list, "通防审核数据");
    }

    /**
     * 获取通防审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:measuresExamine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(preventionExamineService.selectPreventionExamineById(id));
    }

    /**
     * 新增通防审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:measuresExamine:add')")
    @Log(title = "通防审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PreventionExamine preventionExamine)
    {
        return toAjax(preventionExamineService.insertPreventionExamine(preventionExamine));
    }

    /**
     * 修改通防审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:measuresExamine:edit')")
    @Log(title = "通防审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PreventionExamine preventionExamine)
    {
        return toAjax(preventionExamineService.updatePreventionExamine(preventionExamine));
    }

    /**
     * 删除通防审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:measuresExamine:remove')")
    @Log(title = "通防审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(preventionExamineService.deletePreventionExamineByIds(ids));
    }
    /**
     * 查询通防审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:measuresExamine:list')")
    @GetMapping("/getList")
    public TableDataInfo getList(PreventionExamineVo vo) {
        startPage();
        PageInfo<PreventionExamineDto> list = preventionExamineService.getPreventionExamineList(vo);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(list.getList());
        rspData.setTotal(list.getTotal());
        return rspData;
    }
    /**
     * 获取通防审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:measuresExamine:query')")
    @GetMapping(value = "/getPreventionExamineById/{id}")
    public AjaxResult getPreventionExamineById(@PathVariable("id") String id) {
        PreventionExamineDto preventionExamineDto = preventionExamineService.getPreventionExamineById(id);
        return success(preventionExamineDto);
    }
}
